#include "lazy_str.hpp"
lazy_str & lazy_str :: operator += (lazy_str & ls)
{
	char * s = new char[size() + ls.size()];
	strcpy(s, str_);
	if(!is_copy_)
		delete str_;
	else
		is_copy_ = false;
	str_ = s;
	strcat(str_, ls.str_);
	return *this;
}

void lazy_str :: start_own_life()
{
	if(is_copy_)
	{
		char * s = new char[strlen(str_)];
		strcpy(s, str_);
		str_ = s;
		is_copy_ = false;
	}
}

char char_proxy :: operator = (char ch)
{
	ls_.start_own_life();
	ls_.str_[num_] = ch;
	return ls_[num_];
}

char_proxy :: operator char() const {return ls_.str_[num_];}
